import Vue from "vue";
import VueRouter from "vue-router";
import Layout from "../views/layout/index.vue";

Vue.use(VueRouter);
//注意：显示的页面都是 Layout的子页面
const routes = [
  {
    path: "/",
    name: "Layout",
    redirect: "/home",
    component: Layout,
    meta: { title: "首页" }, //路由元信息
    children: [
      {
        path: "home",
        name: "home",
        meta: { title: "首页" },
        component: () =>
          import(/* webpackChunkName: "home" */ "../views/home/index.vue"),
      },
    ],
  },
  //商品的路由信息
  {
    path: "/pms",
    name: "Layout",
    redirect: "/pms/product",
    meta: { title: "商品" },
    component: Layout,
    children: [
      {
        path: "product",
        name: "product",
        meta: { title: "商品列表" },
        component: () =>
          import(
            /* webpackChunkName: "product" */ "../views/pms/product/index.vue"
          ),
      },
      {
        path: "addproduct",
        name: "addproduct",
        meta: { title: "添加商品" },
        component: () =>
          import(
            /* webpackChunkName: "addproduct" */ "../views/pms/product/add.vue"
          ),
      },
      {
        path: "updateproduct/:id",
        name: "updateproduct",
        meta: { title: "修改商品" },
        component: () =>
          import(
            /* webpackChunkName: "updateproduct" */ "../views/pms/product/update.vue"
          ),
      },
      {
        path: "productAttr",
        name: "productAttr",
        meta: { title: "商品类型" },
        component: () =>
          import(
            /* webpackChunkName: "productAttr" */ "../views/pms/productAttr/index.vue"
          ),
      },
      {
        path: "productCate",
        name: "productCate",
        meta: { title: "商品分类" },
        component: () =>
          import(
            /* webpackChunkName: "productCate" */ "../views/pms/productCate/index.vue"
          ),
      },
      {
        path: "addproductCate",
        name: "addproductCate",
        meta: { title: "添加商品分类" },
        component: () =>
          import(
            /* webpackChunkName: "addproductCate" */ "../views/pms/productCate/add.vue"
          ),
      },
      {
        path: "brand",
        name: "brand",
        meta: { title: "商品品牌" },
        component: () =>
          import(
            /* webpackChunkName: "brand" */ "../views/pms/brand/index.vue"
          ),
      },
    ],
  },
  {
    path: "/login",
    name: "Login",
    component: () =>
      import(/* webpackChunkName: "login" */ "../views/login/index.vue"),
  },
  {
    path: "*",
    name: "404",
    component: () => import(/* webpackChunkName: "404" */ "../views/404.vue"),
  },
];

const router = new VueRouter({
  routes,
});

export default router;
